<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>for-in</title>
</head>
<body>

</body>
<script>

    var employees = [{
        id:1,
        name:'Lee',
        age:34
    },{
        id:2,
        name:"Mat",
        age:45
    }]

    var employee1 = {
        id:12,
        name:'Mary',
        age:67
    }

    /**1. 循环数组*/

   /* for(var key in employees){
        document.write(key);
        document.write("-")
        document.write(employees[key].name);
        document.write("-")
        document.write(employees[key].age);
        document.write("<br/>");
    }*/

      // employee.name   employee['name']

    /** 2. 循环对象 */
   /* for(var key in employee1){
        document.write(key);
        document.write("-")
        document.write(employee1[key]);
        document.write("<br/>");
    }
*/
    /** 循环对象数组*/

    for(var key in employees){
        document.write(key);
        document.write("-")

        /** 当 key=0,innerKey = name
         *  employees[0]['name']
         * */
      for(var innerKey in employees[key])  {

          document.write(innerKey)
          document.write("-")
          document.write( employees[key][innerKey]) ;
          document.write("-")

      }
        document.write("<br/>");
    }

</script>
</html>